strcmp(str1,str2)
strcat(str1,str2)
变长度输入参数列表
nargin
表示输入的变长度参数列表中参数个数varargin
表示输入的变长度参数列表例子如下
% define function with variable arguments
function varlist(varargin)
fprintf('Number of arguments: %d\n',nargin)
celldisp(varargin)
% call this function
varlist(ones(3),'some text',pi)
% Output
Number of arguments: 3
varargin{1} =
1 1 1
1 1 1
1 1 1
varargin{2} =
some text
varargin{3} =
3.1416
fig.PaperPosition
should not be so large in terms of
inches
as the unit. Otherwise, out of memory exception will
be raised.print
to save fig with customization.case_name = 'ShuOsher';
fig = figure;
ax = axes('Parent',fig);
hold(ax,'on');
data_fname='WENO_P4N2048_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data = load(data_fpath);
weno_x = data.x;
data_fname='WENO_P4N2048_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data = load(data_fpath);
weno_q = data.q;
weno_rho = weno_q(:,1);
plot(weno_x,weno_rho,'-', 'LineWidth', 3); hold on;
%==============================
SP = 'Gauss';
% plot_case = 'POrder_PWENO_N100';
% plot_case = 'POrder_PWENO_N200';
plot_case = 'POrder_HWENO_N200';
%==============================
if strcmp(plot_case, 'POrder_PWENO_N100')
%
data_fname = 'DG_PWENOLimiter_P2N100_KXRCF_2E-03_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_PWENOLimiter_P2N100_KXRCF_2E-03_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
pweno_p2n100_2e3_x = data_x.x;
p2n100_2e3_q = data_q.q;
pweno_p2n100_2e3_rho = p2n100_2e3_q(:,:,1);
%
data_fname = 'DG_PWENOLimiter_P3N100_KXRCF_2E-03_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_PWENOLimiter_P3N100_KXRCF_2E-03_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
pweno_p3n100_2e3_x = data_x.x;
p3n100_2e3_q = data_q.q;
pweno_p3n100_2e3_rho = p3n100_2e3_q(:,:,1);
%
data_fname = 'DG_PWENOLimiter_P4N100_KXRCF_1E-03_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_PWENOLimiter_P4N100_KXRCF_1E-03_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
pweno_p4n100_1e3_x = data_x.x;
p4n100_1e3_q = data_q.q;
pweno_p4n100_1e3_rho = p4n100_1e3_q(:,:,1);
%
data_fname = 'DG_PWENOLimiter_P5N100_KXRCF_1E-03_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_PWENOLimiter_P5N100_KXRCF_1E-03_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
pweno_p5n100_1e3_x = data_x.x;
p5n100_1e3_q = data_q.q;
pweno_p5n100_1e3_rho = p5n100_1e3_q(:,:,1);
%
if strcmp(SP,'Gauss')
plt = plot( ...
pweno_p2n100_2e3_x(:),pweno_p2n100_2e3_rho(:),'--', ...
pweno_p3n100_2e3_x(:),pweno_p3n100_2e3_rho(:),'--', ...
pweno_p4n100_1e3_x(:),pweno_p4n100_1e3_rho(:),'--', ...
pweno_p5n100_1e3_x(:),pweno_p5n100_1e3_rho(:),'--', ...
'LineWidth', 2);
elseif strcmp(SP, 'CellCenter')
plt = plot( ...
mean(pweno_p2n100_2e3_x,1),mean(pweno_p2n100_2e3_rho,1),'--', ...
mean(pweno_p3n100_2e3_x,1),mean(pweno_p3n100_2e3_rho,1),'--', ...
mean(pweno_p4n100_1e3_x,1),mean(pweno_p4n100_1e3_rho,1),'--', ...
mean(pweno_p5n100_1e3_x,1),mean(pweno_p5n100_1e3_rho,1),'--', ...
'LineWidth', 2);
end
lgd=legend('WENO-P4-N2048', ...
'DG-KXRCF-PWENO-P2-N100-2E-3', ...
'DG-KXRCF-PWENO-P3-N100-2E-3', ...
'DG-KXRCF-PWENO-P4-N100-1E-3', ...
'DG-KXRCF-PWENO-P5-N100-1E-3');
%==============================
elseif strcmp(plot_case, 'POrder_PWENO_N200')
%
data_fname = 'DG_PWENOLimiter_P2N200_KXRCF_1E-03_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_PWENOLimiter_P2N200_KXRCF_1E-03_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
pweno_p2n200_1e3_x = data_x.x;
p2n200_1e3_q = data_q.q;
pweno_p2n200_1e3_rho = p2n200_1e3_q(:,:,1);
%
data_fname = 'DG_PWENOLimiter_P3N200_KXRCF_5E-04_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_PWENOLimiter_P3N200_KXRCF_5E-04_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
pweno_p3n200_5e4_x = data_x.x;
p3n200_5e4_q = data_q.q;
pweno_p3n200_5e4_rho = p3n200_5e4_q(:,:,1);
%
data_fname = 'DG_PWENOLimiter_P4N200_KXRCF_5E-04_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_PWENOLimiter_P4N200_KXRCF_5E-04_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
pweno_p4n200_5e4_x = data_x.x;
p4n200_5e4_q = data_q.q;
pweno_p4n200_5e4_rho = p4n200_5e4_q(:,:,1);
%
if strcmp(SP,'Gauss')
plt = plot( ...
pweno_p2n200_1e3_x(:),pweno_p2n200_1e3_rho(:),'--', ...
pweno_p3n200_5e4_x(:),pweno_p3n200_5e4_rho(:),'--', ...
pweno_p4n200_5e4_x(:),pweno_p4n200_5e4_rho(:),'--', ...
'LineWidth', 2);
elseif strcmp(SP, 'CellCenter')
plt = plot( ...
mean(pweno_p2n200_1e3_x,1),mean(pweno_p2n200_1e3_rho,1),'--', ...
mean(pweno_p3n200_5e4_x,1),mean(pweno_p3n200_5e4_rho,1),'--', ...
mean(pweno_p4n200_5e4_x,1),mean(pweno_p4n200_5e4_rho,1),'--', ...
'LineWidth', 2);
end
lgd = legend('WENO-P4-N2048', ...
'DG-KXRCF-PWENO-P2-N200-1E-3', ...
'DG-KXRCF-PWENO-P3-N200-5E-4', ...
'DG-KXRCF-PWENO-P4-N200-5E-4');
%==============================
elseif strcmp(plot_case, 'POrder_HWENO_N200')
%
data_fname = 'DG_HWENOLimiter_P2N200_KXRCF_2E-03_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_HWENOLimiter_P2N200_KXRCF_2E-03_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
hweno_p2n200_2e3_x = data_x.x;
p2n200_2e3_q = data_q.q;
hweno_p2n200_2e3_rho = p2n200_2e3_q(:,:,1);
%
data_fname = 'DG_HWENOLimiter_P3N200_KXRCF_1E-03_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_HWENOLimiter_P3N200_KXRCF_1E-03_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
hweno_p3n200_1e3_x = data_x.x;
p3n200_1e3_q = data_q.q;
hweno_p3n200_1e3_rho = p3n200_1e3_q(:,:,1);
%
data_fname = 'DG_HWENOLimiter_P3N200_KXRCF_5E-04_X.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_x = load(data_fpath);
data_fname = 'DG_HWENOLimiter_P3N200_KXRCF_5E-04_Q.mat';
data_fpath = strcat(case_name, '/', data_fname);
data_q = load(data_fpath);
hweno_p3n200_5e4_x = data_x.x;
p3n200_5e4_q = data_q.q;
hweno_p3n200_5e4_rho = p3n200_5e4_q(:,:,1);
%
if strcmp(SP,'Gauss')
plt = plot( ...
hweno_p2n200_2e3_x(:),hweno_p2n200_2e3_rho(:),'--', ...
hweno_p3n200_1e3_x(:),hweno_p3n200_1e3_rho(:),'--', ...
hweno_p3n200_5e4_x(:),hweno_p3n200_5e4_rho(:),'--', ...
'LineWidth', 2);
elseif strcmp(SP, 'CellCenter')
plt = plot( ...
mean(hweno_p2n200_2e3_x,1),mean(hweno_p2n200_2e3_rho,1),'--', ...
mean(hweno_p3n200_1e3_x,1),mean(hweno_p3n200_1e3_rho,1),'--', ...
mean(hweno_p3n200_5e4_x,1),mean(hweno_p3n200_5e4_rho,1),'--', ...
'LineWidth', 2);
end
lgd = legend('WENO-P4-N2048', ...
'DG-KXRCF-HWENO-P2-N200-2E-3', ...
'DG-KXRCF-HWENO-P3-N200-5E-4', ...
'DG-KXRCF-HWENO-P3-N200-1E-3');
end
%==============================
lgd.FontSize = 14;
lgd.Location = 'southwest';
set(ax,'FontName','Cascadia Code PL','FontSize',14, ...
'GridLineStyle',':','XGrid','on','YGrid','on');
box(ax,'on');
fig = gcf;
fig.PaperUnits = 'inches';
fig.PaperPosition = [0 0 16 8];
fig.PaperPositionMode = 'manual';
%==============================
xlim([-5,5]);
ylim([0.5,5]);
fig_fname = strcat(plot_case,'_FullRegion.png');
fig_fpath = strcat(case_name,'/',fig_fname);
print(fig_fpath,'-dpng','-r0');
xlim([0.6,2.4]);
ylim([3,4.7]);
fig_fname = strcat(plot_case,'_CoreRegion.png');
fig_fpath = strcat(case_name,'/',fig_fname);
print(fig_fpath,'-dpng','-r0');
nohup matlab -nosplash -nodisplay -nodesktop -r 'try; ScriptName; catch; end; quit' > output.log &